<?php

require('base.php');

class Solution extends Base {
	
	function Solution() {
		parent::Base();
		$this->database();
	}
	
	function index($language) {
		$this->language( $language, 'base' );
		
		$solution_list = $this->db->find("select * from solution where language='$language'");
		
		$page = $this->db->find_row("select * from page where language='$language' and url_pattern='solution'");
		
		$meta = array(
			'title' 		=> $page['title'],
			'keywords'		=> $page['keywords'],
			'description'	=> $page['description']
		);
		
		$data = array(
			'solution_list' => $solution_list,
			'meta'			=> $meta
		);
		
		$this->layout('portal/solution_list', $data);
	}
	
	function show($up, $language) {
		$this->language( $language, 'base' );

		$sql = "select * from solution where url_pattern='$up' and language='$language'";
		$solution = $this->db->find_row($sql);
		$meta = array(
			'title' 		=> $solution['title'],
			'keywords'		=> $solution['keywords'],
			'description'	=> $solution['description']
		);
		
		// 获取上 一条方案记录
		$pre_solution_sql = "select name, url_pattern from solution where language='$language' and id < "
			. $solution['id'] ." order by id desc limit 0,1";
		$pre_solution = $this->db->find_row($pre_solution_sql);

		// 获取下一条方案记录
		$next_solution_sql = "select name, url_pattern from solution where language='$language' and id > "
			. $solution['id'] ." order by id limit 0,1";	
		$next_solution = $this->db->find_row($next_solution_sql);
		
		$data = array(
			'solution' 		=> $solution,
			'pre_solution' 	=> $pre_solution,
			'next_solution' => $next_solution,
			'meta'			=> $meta
		);
		$this->layout('portal/solution', $data);
	}
	
}

?>